const {
    WindowManager
} = require('node-window-manager');
const wm = new WindowManager();

// 定时检查微信窗口标题（每1秒一次）
setInterval(() => {
    const windows = wm.getWindows();
    const wechatWindow = windows.find(w => w.getTitle().includes('微信'));

    if (wechatWindow) {
        const title = wechatWindow.getTitle();
        // 检测标题中的未读标识（如“微信 (3)”）
        if (/微信 \(\d+\)/.test(title)) {
            console.log('有新消息，触发截屏');
            captureAndProcess(); // 调用截屏和识别逻辑
        }
    }
}, 1000);